using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using CoachingOrganizer.Logic.Models.Tools.MoodLevel;

namespace CoachingOrganizer.Android.Adapters.Tools.MoodLevel
{
    public class MoodDaysAdapter : BaseAdapter
    {
        private readonly Activity _context;
        private readonly List<MoodDayCacheModel> _items;
        private readonly MoodLevelModel _model;

        public MoodDaysAdapter(Activity context, MoodLevelModel model)
            : base()
        {
            _context = context;
            _model = model;
            _items = model.Days.ToList();
        }

        public override Java.Lang.Object GetItem(int position)
        {
            return position;
        }

        public override long GetItemId(int position)
        {
            return position;
        }

        public override int Count
        {
            get { return _items.Count; }
        }

        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = _context.LayoutInflater.Inflate(Resource.Layout.MoodDayLayout, parent, false);
            HookModelToView(view, _items[position]);
            return view;
        }

        private void HookModelToView(View view, MoodDayCacheModel moodDayCacheModel)
        {
            TextView moodDayDateTextView = view.FindViewById<TextView>(Resource.Id.moodDayDateTextView);
            moodDayDateTextView.Text = moodDayCacheModel.Date.ToLongDateString();
        }
    }
}